home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Other / upsd / ups_folder / patch03.script < prev    next >
Encoding:
Text File  |  1991-05-01  |  21.4 KB  |  754 lines

  1. #! /bin/sh
  2. # This is a shell archive.  Remove anything before this line, then unpack
  3. # it by saving it into a file and typing "sh file".  To overwrite existing
  4. # files, type "sh file -c".  You can also feed this as standard input via
  5. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  6. # will see the following message at the end:
  7. #        "End of shell archive."
  8. # Contents:  Patch03 upsd.1 upsfail upsrest
  9. # Wrapped by root@pilikia on Mon Apr 15 23:27:34 1991
  10. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  11. if test -f 'Patch03' -a "${1}" != "-c" ; then 
  12.   echo shar: Will not clobber existing file \"'Patch03'\"
  13. else
  14. echo shar: Extracting \"'Patch03'\" \(15648 characters\)
  15. sed "s/^X//" >'Patch03' <<'END_OF_FILE'
  16. X*** HISTORY.orig    Mon Apr 15 23:25:28 1991
  17. X--- HISTORY    Mon Apr 15 23:26:03 1991
  18. X***************
  19. X*** 1,3 ****
  20. X--- 1,4 ----
  21. X+ 
  22. X  UPSD RELEASE HISTORY    art@pilikia.pegasus.com
  23. X  
  24. X  Date      Release  Patch  Description
  25. X***************
  26. X*** 7,9 ****
  27. X--- 8,13 ----
  28. X                            added version stuff.
  29. X  04/10/91  1.0      2      Added log file locking, only 1 upsd can be running
  30. X                            now.  Also added date to version string.
  31. X+ 04/15/91  1.0      3      Added broadcast of power fail and restore messages,
  32. X+                           defined message file names as new command line and
  33. X+                           environment variable parameters.  Also made man page.
  34. X*** MANIFEST.orig    Mon Apr 15 23:25:28 1991
  35. X--- MANIFEST    Mon Apr 15 23:26:03 1991
  36. X***************
  37. X*** 8,11 ****
  38. X--- 8,14 ----
  39. X   funcs.c                    1    Functions 
  40. X   main.c                     1    Main program
  41. X   ups                        1    Init.d startup script
  42. X+  upsd.1                     1    Upsd man page
  43. X+  upsfail                    1    UPS failure message file
  44. X+  upsrest                    1    UPS restore message file
  45. X   version.h                  1    Version control header
  46. X*** Makefile.orig    Mon Apr 15 23:25:28 1991
  47. X--- Makefile    Mon Apr 15 23:26:03 1991
  48. X***************
  49. X*** 11,24 ****
  50. X  CC = cc
  51. X  DEFS =
  52. X  CFLAGS = -O $(DEFS)
  53. X  CFILES = main.c funcs.c
  54. X  OFILES = main.o funcs.o
  55. X  HFILES = common.h
  56. X! LIBES =
  57. X  DESTDIR = /etc
  58. X  INITDIR = /etc/init.d
  59. X  RC2DIR = /etc/rc2.d
  60. X  RC2NUM = 22
  61. X  
  62. X  upsd: $(OFILES)
  63. X      $(CC) $(CFLAGS) $(OFILES) -o $@ $(LIBES)
  64. X--- 11,27 ----
  65. X  CC = cc
  66. X  DEFS =
  67. X  CFLAGS = -O $(DEFS)
  68. X+ LIBES =
  69. X+ 
  70. X  CFILES = main.c funcs.c
  71. X  OFILES = main.o funcs.o
  72. X  HFILES = common.h
  73. X! 
  74. X  DESTDIR = /etc
  75. X  INITDIR = /etc/init.d
  76. X  RC2DIR = /etc/rc2.d
  77. X  RC2NUM = 22
  78. X+ MANDIR = /usr/catman/u_man/man1
  79. X  
  80. X  upsd: $(OFILES)
  81. X      $(CC) $(CFLAGS) $(OFILES) -o $@ $(LIBES)
  82. X***************
  83. X*** 31,37 ****
  84. X      chgrp sys $(DESTDIR)/upsd
  85. X      chmod 550 $(DESTDIR)/upsd
  86. X  
  87. X! install_rc: install
  88. X      cp ups $(INITDIR)/ups
  89. X      chown root $(INITDIR)/ups
  90. X      chgrp sys $(INITDIR)/ups
  91. X--- 34,40 ----
  92. X      chgrp sys $(DESTDIR)/upsd
  93. X      chmod 550 $(DESTDIR)/upsd
  94. X  
  95. X! install_rc:
  96. X      cp ups $(INITDIR)/ups
  97. X      chown root $(INITDIR)/ups
  98. X      chgrp sys $(INITDIR)/ups
  99. X***************
  100. X*** 38,43 ****
  101. X--- 41,57 ----
  102. X      chmod 744 $(INITDIR)/ups
  103. X      ln $(INITDIR)/ups $(RC2DIR)/S$(RC2NUM)ups
  104. X  
  105. X+ install_msg:
  106. X+     cp upsfail upsrest $(DESTDIR)
  107. X+     chown root $(DESTDIR)/upsfail $(DESTDIR)/upsrest
  108. X+     chgrp sys $(DESTDIR)/upsfail $(DESTDIR)/upsrest
  109. X+     chmod 644 $(DESTDIR)/upsfail $(DESTDIR)/upsrest
  110. X+ 
  111. X+ install_man:
  112. X+     rm -f $(MANDIR)/upsd.1.z
  113. X+     nroff -man upsd.1 > $(MANDIR)/upsd.1
  114. X+     pack $(MANDIR)/upsd.1
  115. X+ 
  116. X  indent:
  117. X      @for f in $(CFILES); do \
  118. X          indent $$f; \
  119. X***************
  120. X*** 50,56 ****
  121. X      rm -f upsd core *.o *.BAK Part*
  122. X  
  123. X  clobber: clean
  124. X!     rm -f $(DESTDIR)/upsd $(INITDIR)/ups $(RC2DIR)/S$(RC2NUM)ups
  125. X  
  126. X  # dependencies
  127. X  main.o:        main.c $(HFILES)
  128. X--- 64,71 ----
  129. X      rm -f upsd core *.o *.BAK Part*
  130. X  
  131. X  clobber: clean
  132. X!     rm -f $(DESTDIR)/upsd $(DESTDIR)/upsfail $(DESTDIR)/upsrest
  133. X!     rm -f $(INITDIR)/ups $(RC2DIR)/S$(RC2NUM)ups
  134. X  
  135. X  # dependencies
  136. X  main.o:        main.c $(HFILES)
  137. X*** README.orig    Mon Apr 15 23:25:28 1991
  138. X--- README    Mon Apr 15 23:26:03 1991
  139. X***************
  140. X*** 1,4 ****
  141. X!      Tue Apr 02 23:24:20 HST 1991    art@pilikia.pegasus.com        Pg. 1
  142. X   
  143. X  
  144. X      INTRODUCTION
  145. X--- 1,4 ----
  146. X!      upsd release 03/30/91 version 1.0 patchlevel 3            Pg. 1
  147. X   
  148. X  
  149. X      INTRODUCTION
  150. X***************
  151. X*** 24,30 ****
  152. X      in the /etc directory when the install target is made.  
  153. X  
  154. X  
  155. X!      Tue Apr 02 23:24:20 HST 1991    art@pilikia.pegasus.com        Pg. 2
  156. X  
  157. X  
  158. X      COMMAND LINE OPTIONS
  159. X--- 24,30 ----
  160. X      in the /etc directory when the install target is made.  
  161. X  
  162. X  
  163. X!      upsd release 03/30/91 version 1.0 patchlevel 3            Pg. 2
  164. X  
  165. X  
  166. X      COMMAND LINE OPTIONS
  167. X***************
  168. X*** 34,43 ****
  169. X      take precedence to the environment variable settings, and are
  170. X      as follows:
  171. X  
  172. X!     usage: upsd [-d tty][-c cmd][-l log][-t min]
  173. X          -d tty        pathname of UPS device
  174. X          -c cmd        pathname of shutdown command
  175. X!         -l log        pathname of UPS log file
  176. X          -t min        delay time in minutes
  177. X  
  178. X      The -d tty option must specify the full pathname (including the
  179. X--- 34,45 ----
  180. X      take precedence to the environment variable settings, and are
  181. X      as follows:
  182. X  
  183. X!     usage: upsd [-d tty][-c cmd][-l file][-t min][-f file][-r file]
  184. X          -d tty        pathname of UPS device
  185. X          -c cmd        pathname of shutdown command
  186. X!         -l file        pathname of UPS log file
  187. X!         -f file        pathname of UPS fail message file
  188. X!         -r file        pathname of UPS restore message file
  189. X          -t min        delay time in minutes
  190. X  
  191. X      The -d tty option must specify the full pathname (including the
  192. X***************
  193. X*** 53,61 ****
  194. X  
  195. X      Example:
  196. X  
  197. X!     upsd -d /dev/ttyFM00 -c "/etc/shutdown -y -g1 -i0"
  198. X  
  199. X!     The -l option specified the logfile upsd will write it's event
  200. X      messages to, these messages give the date and time that the UPS
  201. X      daemon started, switched to battery, switched back to online,
  202. X      executed the shutdown command, or was terminated via SIGTERM.
  203. X--- 55,63 ----
  204. X  
  205. X      Example:
  206. X  
  207. X!     upsd -c "/etc/shutdown -y -i0"
  208. X  
  209. X!     The -l option specifies the logfile upsd will write it's event
  210. X      messages to, these messages give the date and time that the UPS
  211. X      daemon started, switched to battery, switched back to online,
  212. X      executed the shutdown command, or was terminated via SIGTERM.
  213. X***************
  214. X*** 62,69 ****
  215. X  
  216. X      Example:
  217. X  
  218. X!     upsd -d /dev/ttyFM00 -c "/etc/shutdown -y -g1 -i0" -l /etc/upslog
  219. X  
  220. X      Finally, the -t option specifies the number of minutes to allow
  221. X      the UPS to be on battery backup before executing the shutdown
  222. X      sequence.  This number must be between 1 and 30.  Be careful not
  223. X--- 64,91 ----
  224. X  
  225. X      Example:
  226. X  
  227. X!     upsd -l /etc/upslog
  228. X  
  229. X+     The -f option specifies the path name of the failure message file
  230. X+     to broadcast to all users in the event of a power failure.  The
  231. X+     failure message file is simply an ASCII text file which you can
  232. X+     create with an editor such as vi(1). If the file is not found by
  233. X+     upsd, no message will be broadcast upon power failure.
  234. X+ 
  235. X+     Example:
  236. X+ 
  237. X+     upsd -f /etc/upsfail
  238. X+ 
  239. X+     The -r option specifies the path name of the restore message file
  240. X+     to broadcast to all users in the event of power restore.  The
  241. X+     restore message file is simply an ASCII text file which you can
  242. X+     create with an editor such as vi(1). If the file is not found by
  243. X+     upsd, no message will be broadcast upon power restore.
  244. X+ 
  245. X+     Example:
  246. X+ 
  247. X+     upsd -f /etc/upsrest
  248. X+ 
  249. X      Finally, the -t option specifies the number of minutes to allow
  250. X      the UPS to be on battery backup before executing the shutdown
  251. X      sequence.  This number must be between 1 and 30.  Be careful not
  252. X***************
  253. X*** 73,81 ****
  254. X  
  255. X      Example:
  256. X  
  257. X!     upsd -d /dev/ttyFM00 -c "/etc/shutdown -y -g1 -i0" -l /etc/upslog -t 10
  258. X      
  259. X!      Tue Apr 02 23:24:20 HST 1991    art@pilikia.pegasus.com        Pg. 3
  260. X  
  261. X  
  262. X      ENVIRONMENT VARIABLES
  263. X--- 95,103 ----
  264. X  
  265. X      Example:
  266. X  
  267. X!     upsd -t 10
  268. X      
  269. X!      upsd release 03/30/91 version 1.0 patchlevel 3            Pg. 3
  270. X  
  271. X  
  272. X      ENVIRONMENT VARIABLES
  273. X***************
  274. X*** 88,95 ****
  275. X      Environment    Equivalent        Default
  276. X      Variable    Command line option    Value
  277. X      UPSPORT            -p        /dev/ttyFM00
  278. X!     UPSSHUT            -c        "/etc/shutdown -y -g1 -i0"
  279. X      UPSLOG            -l        /etc/upslog
  280. X      UPSTIME            -t        10
  281. X  
  282. X      Note that the compiled in default values can be altered in common.h
  283. X--- 110,119 ----
  284. X      Environment    Equivalent        Default
  285. X      Variable    Command line option    Value
  286. X      UPSPORT            -p        /dev/ttyFM00
  287. X!     UPSSHUT            -c        "/etc/shutdown -y -i0"
  288. X      UPSLOG            -l        /etc/upslog
  289. X+     UPSFAIL            -f        /etc/upsfail
  290. X+     UPSREST            -r        /etc/upsrest
  291. X      UPSTIME            -t        10
  292. X  
  293. X      Note that the compiled in default values can be altered in common.h
  294. X*** common.h.orig    Mon Apr 15 23:25:28 1991
  295. X--- common.h    Mon Apr 15 23:26:03 1991
  296. X***************
  297. X*** 22,39 ****
  298. X  
  299. X  #define ERR        -1        /* error return value */
  300. X  #define SH        "/bin/sh"    /* shell to exec shutdown command */
  301. X! #define ROOT        "/"        /* root directory for chdir */
  302. X  #define CONSOLE        "/dev/console"    /* console device */
  303. X  #define SECS_PER_MIN    60        /* number of secs in a minute */
  304. X  #define MAX_TIME    30        /* maximum delay time allowed */
  305. X- #define SHUT_PERMS    0500        /* shutdown command permissions mask */
  306. X  #define LOG_PERMS    0600        /* logfile permissions on create */
  307. X  #define LOG_FLAGS    O_WRONLY | O_CREAT | O_APPEND    /* logfile open flags */
  308. X  
  309. X  /* default tuneable parameter values */
  310. X  #define UPS_PORT    "/dev/ttyFM00"    /* UPS port device name */
  311. X! #define UPS_SHUT    "/etc/shutdown -y -g0"    /* shutdown command */
  312. X  #define UPS_LOG        "/etc/upslog"    /* UPS log file pathname */
  313. X  #define UPS_TIME    10        /* default delay time (minutes) */
  314. X  
  315. X  /* environment variable names */
  316. X--- 22,41 ----
  317. X  
  318. X  #define ERR        -1        /* error return value */
  319. X  #define SH        "/bin/sh"    /* shell to exec shutdown command */
  320. X! #define WALL        "/etc/wall"    /* utility to broadcast messages */
  321. X  #define CONSOLE        "/dev/console"    /* console device */
  322. X+ #define ROOT        "/"        /* root directory for chdir */
  323. X  #define SECS_PER_MIN    60        /* number of secs in a minute */
  324. X  #define MAX_TIME    30        /* maximum delay time allowed */
  325. X  #define LOG_PERMS    0600        /* logfile permissions on create */
  326. X  #define LOG_FLAGS    O_WRONLY | O_CREAT | O_APPEND    /* logfile open flags */
  327. X  
  328. X  /* default tuneable parameter values */
  329. X  #define UPS_PORT    "/dev/ttyFM00"    /* UPS port device name */
  330. X! #define UPS_SHUT    "/etc/shutdown -y -i0"    /* shutdown command */
  331. X  #define UPS_LOG        "/etc/upslog"    /* UPS log file pathname */
  332. X+ #define UPS_FAIL    "/etc/upsfail"    /* UPS fail message file name */
  333. X+ #define UPS_REST    "/etc/upsrest"    /* UPS restore message file name */
  334. X  #define UPS_TIME    10        /* default delay time (minutes) */
  335. X  
  336. X  /* environment variable names */
  337. X***************
  338. X*** 40,45 ****
  339. X--- 42,49 ----
  340. X  #define UPSPORT        "UPSPORT"
  341. X  #define UPSSHUT        "UPSSHUT"
  342. X  #define UPSLOG        "UPSLOG"
  343. X+ #define UPSFAIL        "UPSFAIL"
  344. X+ #define UPSREST        "UPSREST"
  345. X  #define UPSTIME        "UPSTIME"
  346. X  
  347. X  /* UPS log messages */
  348. X***************
  349. X*** 54,59 ****
  350. X--- 58,65 ----
  351. X  extern char   *ups_port;        /* UPS device name */
  352. X  extern char   *ups_shut;        /* system shutdown command */
  353. X  extern char   *ups_log;            /* UPS log file name */
  354. X+ extern char   *ups_fail;        /* UPS failure message file name */
  355. X+ extern char   *ups_rest;        /* UPS restore message file name */
  356. X  extern int     ups_time;        /* delay time before shutdown */
  357. X  extern int     ups_fd;            /* UPS port descriptor */
  358. X  extern int     log_fd;            /* log file descriptor */
  359. X*** funcs.c.orig    Mon Apr 15 23:25:28 1991
  360. X--- funcs.c    Mon Apr 15 23:26:03 1991
  361. X***************
  362. X*** 26,31 ****
  363. X--- 26,35 ----
  364. X          ups_shut = s;
  365. X      if ((s = getenv(UPSLOG)) != NULL)
  366. X          ups_log = s;
  367. X+     if ((s = getenv(UPSFAIL)) != NULL)
  368. X+         ups_fail = s;
  369. X+     if ((s = getenv(UPSREST)) != NULL)
  370. X+         ups_rest = s;
  371. X      if ((s = getenv(UPSTIME)) != NULL)
  372. X          ups_time = atoi(s);
  373. X  }
  374. X***************
  375. X*** 52,58 ****
  376. X      version(av[0]);
  377. X  
  378. X      /* parse the command line */
  379. X!     while ((c = getopt(ac, av, "d:c:l:t:")) != EOF)
  380. X          switch (c) {
  381. X          case 'd':    /* device option */
  382. X              ups_port = optarg;
  383. X--- 56,62 ----
  384. X      version(av[0]);
  385. X  
  386. X      /* parse the command line */
  387. X!     while ((c = getopt(ac, av, "d:c:l:f:r:t:")) != EOF)
  388. X          switch (c) {
  389. X          case 'd':    /* device option */
  390. X              ups_port = optarg;
  391. X***************
  392. X*** 63,68 ****
  393. X--- 67,78 ----
  394. X          case 'l':    /* logfile option */
  395. X              ups_log = optarg;
  396. X              break;
  397. X+         case 'f':    /* failure option */
  398. X+             ups_fail = optarg;
  399. X+             break;
  400. X+         case 'r':    /* restore option */
  401. X+             ups_rest = optarg;
  402. X+             break;
  403. X          case 't':    /* time option */
  404. X              ups_time = atoi(optarg);
  405. X              break;
  406. X***************
  407. X*** 76,81 ****
  408. X--- 86,92 ----
  409. X  **    c h k o p t i o n s
  410. X  **
  411. X  **    check runtime options
  412. X+ **    with various sanity tests
  413. X  */
  414. X  void
  415. X  chkoptions()
  416. X***************
  417. X*** 103,111 ****
  418. X          perror(ups_shut);
  419. X          exit(1);
  420. X      }
  421. X!     /* and must be readable/executable by owner */
  422. X!     if (!(st.st_mode & SHUT_PERMS)) {
  423. X!         fprintf(stderr, "%s must be readable/executable by owner\n", ups_port);
  424. X          exit(1);
  425. X      }
  426. X      /* delay time must be > 0 and <= MAX_TIME */
  427. X--- 114,122 ----
  428. X          perror(ups_shut);
  429. X          exit(1);
  430. X      }
  431. X!     /* and must be a regular file */
  432. X!     if ((st.st_mode & S_IFMT) != S_IFREG) {
  433. X!         fprintf(stderr, "%s not regular\n", ups_port);
  434. X          exit(1);
  435. X      }
  436. X      /* delay time must be > 0 and <= MAX_TIME */
  437. X***************
  438. X*** 127,132 ****
  439. X--- 138,144 ----
  440. X  
  441. X      void    sigcatch();
  442. X      void    writelog();
  443. X+     void    writeall();
  444. X      void    shutdown();
  445. X  
  446. X      if (!fork()) {
  447. X***************
  448. X*** 166,171 ****
  449. X--- 178,186 ----
  450. X          }
  451. X          writelog(BATTERY_MSG);
  452. X  
  453. X+         /* broadcast failure message */
  454. X+         writeall(ups_fail);
  455. X+ 
  456. X          /* set the alarm clock */
  457. X          alarm(ups_time * SECS_PER_MIN);
  458. X  
  459. X***************
  460. X*** 175,180 ****
  461. X--- 190,198 ----
  462. X  
  463. X          writelog(ONLINE_MSG);
  464. X  
  465. X+         /* broadcast restore message */
  466. X+         writeall(ups_rest);
  467. X+ 
  468. X          close(log_fd);
  469. X          close(ups_fd);
  470. X  
  471. X***************
  472. X*** 191,198 ****
  473. X--- 209,218 ----
  474. X  sigcatch()
  475. X  {
  476. X      writelog(TERM_MSG);
  477. X+ 
  478. X      close(log_fd);
  479. X      close(ups_fd);
  480. X+ 
  481. X      exit(1);
  482. X  }
  483. X  
  484. X***************
  485. X*** 221,226 ****
  486. X--- 241,275 ----
  487. X  }
  488. X  
  489. X  /*
  490. X+ **    w r i t e a l l
  491. X+ **
  492. X+ **    write to all users
  493. X+ */
  494. X+ void
  495. X+ writeall(fn)
  496. X+ char   *fn;
  497. X+ {
  498. X+     struct stat st;
  499. X+     void    attach();
  500. X+ 
  501. X+     /* message file must exist */
  502. X+     if (stat(fn, &st) == ERR)
  503. X+         return;
  504. X+ 
  505. X+     /* and must be a regular file */
  506. X+     if ((st.st_mode & S_IFMT) != S_IFREG)
  507. X+         return;
  508. X+ 
  509. X+     if (!fork()) {
  510. X+ 
  511. X+         attach(CONSOLE);
  512. X+ 
  513. X+         /* write message file to users */
  514. X+         execlp(WALL, WALL, fn, NULL);
  515. X+     }
  516. X+ }
  517. X+ 
  518. X+ /*
  519. X  **    s h u t d o w n
  520. X  **
  521. X  **    shutdown the system
  522. X***************
  523. X*** 232,246 ****
  524. X  
  525. X      writelog(SHUTDOWN_MSG);
  526. X  
  527. X!     close(log_fd);
  528. X!     close(ups_fd);
  529. X  
  530. X!     attach(CONSOLE);
  531. X  
  532. X!     chdir(ROOT);
  533. X  
  534. X!     /* execute shutdown command */
  535. X!     execlp(SH, SH, "-c", ups_shut, NULL);
  536. X  }
  537. X  
  538. X  /*
  539. X--- 281,298 ----
  540. X  
  541. X      writelog(SHUTDOWN_MSG);
  542. X  
  543. X!     close(ups_log);
  544. X!     close(ups_port);
  545. X  
  546. X!     if (!fork()) {
  547. X! 
  548. X!         attach(CONSOLE);
  549. X  
  550. X!         chdir(ROOT);
  551. X  
  552. X!         /* execute shutdown command */
  553. X!         execlp(SH, SH, "-c", ups_shut, NULL);
  554. X!     }
  555. X  }
  556. X  
  557. X  /*
  558. X***************
  559. X*** 314,323 ****
  560. X  {
  561. X      char   *basename();
  562. X  
  563. X!     fprintf(stderr, "usage: %s [-d tty][-c cmd][-l log][-t min][-v]\n",
  564. X!         basename(s));
  565. X      fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n");
  566. X      fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n");
  567. X!     fprintf(stderr, "\t-l log\t\tpathname of UPS log file\n");
  568. X      fprintf(stderr, "\t-t min\t\tdelay time in minutes\n");
  569. X  }
  570. X--- 366,376 ----
  571. X  {
  572. X      char   *basename();
  573. X  
  574. X!     fprintf(stderr, "usage: %s [-d tty][-c cmd][-l file][-f file][-r file][-t min]\n", basename(s));
  575. X      fprintf(stderr, "\t-d tty\t\tpathname of UPS device\n");
  576. X      fprintf(stderr, "\t-c cmd\t\tpathname of shutdown command\n");
  577. X!     fprintf(stderr, "\t-l file\t\tpathname of UPS log file\n");
  578. X!     fprintf(stderr, "\t-f file\t\tpathname of UPS fail message file\n");
  579. X!     fprintf(stderr, "\t-r file\t\tpathname of UPS restore message file\n");
  580. X      fprintf(stderr, "\t-t min\t\tdelay time in minutes\n");
  581. X  }
  582. X*** main.c.orig    Mon Apr 15 23:25:28 1991
  583. X--- main.c    Mon Apr 15 23:26:03 1991
  584. X***************
  585. X*** 14,19 ****
  586. X--- 14,21 ----
  587. X  char   *ups_port = UPS_PORT;
  588. X  char   *ups_shut = UPS_SHUT;
  589. X  char   *ups_log = UPS_LOG;
  590. X+ char   *ups_fail = UPS_FAIL;
  591. X+ char   *ups_rest = UPS_REST;
  592. X  int     ups_time = UPS_TIME;
  593. X  
  594. X  /* global descriptors */
  595. X*** version.h.orig    Mon Apr 15 23:25:28 1991
  596. X--- version.h    Mon Apr 15 23:26:03 1991
  597. X***************
  598. X*** 11,14 ****
  599. X  #define RELEASE_DATE    "03/30/91"
  600. X  #define RELEASE        1
  601. X  #define REVISION    0
  602. X! #define PATCHLEVEL    2
  603. X--- 11,14 ----
  604. X  #define RELEASE_DATE    "03/30/91"
  605. X  #define RELEASE        1
  606. X  #define REVISION    0
  607. X! #define PATCHLEVEL    3
  608. END_OF_FILE
  609. if test 15648 -ne `wc -c <'Patch03'`; then
  610.     echo shar: \"'Patch03'\" unpacked with wrong size!
  611. fi
  612. # end of 'Patch03'
  613. fi
  614. if test -f 'upsd.1' -a "${1}" != "-c" ; then 
  615.   echo shar: Will not clobber existing file \"'upsd.1'\"
  616. else
  617. echo shar: Extracting \"'upsd.1'\" \(2916 characters\)
  618. sed "s/^X//" >'upsd.1' <<'END_OF_FILE'
  619. X.\"upsd release 03/30/91 version 1.0 patchlevel 3
  620. X.TH UPSD 1M
  621. X.SH NAME
  622. Xupsd \- UPS monitor daemon
  623. X.SH SYNOPSIS
  624. X.B /etc/upsd
  625. X[\-d tty] [\-c cmd] [\-l file] [\-f file] [\-r file] [\-t min]
  626. X.SH DESCRIPTION
  627. X.I Upsd
  628. Xmonitors the serial port connected to an UPS device
  629. Xand will perform an unattended shutdown of the system
  630. Xif the UPS is on battery longer than a specified
  631. Xnumber of minutes.
  632. X.I Upsd
  633. Xneeds to watch a tty with modem control properties,
  634. Xand expects the UPS to raise DCD when it switches to
  635. Xbattery backup and drop DCD when it goes back to an
  636. Xonline state.
  637. X.SH OPTIONS
  638. X.I upsd
  639. Xhas the following command line options:
  640. X.IP "-d \fItty\fP"
  641. XSpecifies the full pathname (including the /dev prefix)
  642. Xto the tty device the UPS is on.  This must be a modem
  643. Xcontrol type device.
  644. X.PP
  645. X.IP "-c \fIcmd\fP"
  646. XSpecifies the full pathname of the command to be executed
  647. Xto shut down the system.  This command must be enclosed in
  648. Xquotes if it consists of 2 or more words.
  649. X.PP
  650. X.IP "-l \fIfile\fP"
  651. XSpecifies the logfile
  652. X.I upsd
  653. Xwill write it's event messages to, these messages give the
  654. Xdate and time that the UPS daemon started, switched to battery,
  655. Xswitched back to online, executed the shutdown command, or was
  656. Xterminated via SIGTERM.
  657. X.PP
  658. X.IP "-f \fIfile\fP"
  659. XSpecifies the path name of the failure message file to broadcast
  660. Xto all users in the event of a power failure.  The failure message
  661. Xfile is simply an ASCII text file which you can create with an editor
  662. Xsuch as vi(1). If the file is not found by
  663. X.I upsd
  664. X, no message will be broadcast upon power failure.
  665. X.PP
  666. X.IP "-r \fIfile\fP"
  667. XSpecifies the path name of the restore message file to broadcast
  668. Xto all users in the event of power restore.  The restore message
  669. Xfile is simply an ASCII text file which you can create with an editor
  670. Xsuch as vi(1). If the file is not found by
  671. X.I upsd
  672. X, no message will be broadcast upon power restore.
  673. X.PP
  674. X.IP "-t \fImin\fP"
  675. XSpecifies the number of minutes to allow the UPS to be on battery
  676. Xbackup before executing the shutdown sequence.  This number must
  677. Xbe between 1 and 30.  Be careful not to choose a value greater than
  678. Xthe number of minutes of battery time your UPS supports with your
  679. Xcurrent load.  A value in the 5 to 10 minute range is probably sufficient.
  680. X.PP
  681. X.SH ENVIRONMENT VARIABLES
  682. XThe following environment variables can be set if that interface
  683. Xis preferred to the command line options.  Note that command
  684. Xline options override the environment variable settings.
  685. X.sp
  686. XEnvironment    Equivalent        Default
  687. XVariable        Command line option    Value
  688. XUPSPORT            -p            /dev/ttyFM00
  689. XUPSSHUT            -c            "/etc/shutdown -y -i0"
  690. XUPSLOG            -l            /etc/upslog
  691. XUPSFAIL            -f            /etc/upsfail
  692. XUPSREST            -r            /etc/upsrest
  693. XUPSTIME            -t            10
  694. X.sp
  695. X.SH FILES
  696. X/etc/upslog        upsd event log
  697. X.br
  698. X/etc/upsfail        upsd failure message file
  699. X.br
  700. X/etc/upsrest        upsd restore message file
  701. X.SH SEE ALSO
  702. Xshutdown(1M), wall(1).
  703. X.SH AUTHOR
  704. XArthur W. Neilson III
  705. X.br
  706. Xart@pilikia.pegasus.com
  707. END_OF_FILE
  708. if test 2916 -ne `wc -c <'upsd.1'`; then
  709.     echo shar: \"'upsd.1'\" unpacked with wrong size!
  710. fi
  711. # end of 'upsd.1'
  712. fi
  713. if test -f 'upsfail' -a "${1}" != "-c" ; then 
  714.   echo shar: Will not clobber existing file \"'upsfail'\"
  715. else
  716. echo shar: Extracting \"'upsfail'\" \(188 characters\)
  717. sed "s/^X//" >'upsfail' <<'END_OF_FILE'
  718. XUPS ONLINE POWER FAILED, UPS is now on battery backup power.
  719. XThe system will shut down automatically in 10 minutes if power
  720. Xis not restored.  Please log off the system as soon as you can.
  721. END_OF_FILE
  722. if test 188 -ne `wc -c <'upsfail'`; then
  723.     echo shar: \"'upsfail'\" unpacked with wrong size!
  724. fi
  725. # end of 'upsfail'
  726. fi
  727. if test -f 'upsrest' -a "${1}" != "-c" ; then 
  728.   echo shar: Will not clobber existing file \"'upsrest'\"
  729. else
  730. echo shar: Extracting \"'upsrest'\" \(99 characters\)
  731. sed "s/^X//" >'upsrest' <<'END_OF_FILE'
  732. XUPS ONLINE POWER RESTORED!  UPS now on wall power.
  733. XYou may resume your work and proceed as normal.
  734. END_OF_FILE
  735. if test 99 -ne `wc -c <'upsrest'`; then
  736.     echo shar: \"'upsrest'\" unpacked with wrong size!
  737. fi
  738. # end of 'upsrest'
  739. fi
  740. echo shar: End of shell archive.
  741. exit 0
  742. -----8<----- cut here -----8<----- cut here -----8<----- cut here -----8<-----
  743.  
  744. -- 
  745. Arthur W. Neilson III        | INET: art@pilikia.pegasus.com
  746. Bank of Hawaii Tech Support    | UUCP: uunet!ucsd!nosc!pilikia!art
  747.  
  748. exit 0 # Just in case...
  749. -- 
  750. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  751. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  752. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  753. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  754.